# -*- coding: utf-8 -*-

from django.core.management.base import BaseCommand
from django.db import transaction

class Command(BaseCommand):
    help = "check all users"

    @transaction.commit_on_success
    def handle(self, **options):
        """
        ситуация с deadlock аналогично parselog
        """
        from nstat.traffic.models import UserProfile
        for u in UserProfile.objects.select_for_update().all():
            print u
            u.check()
            u.save()
